package com.flying.scorer.repository.equity;


import com.flying.refdata.model.equity.EquityInfo;
import com.flying.refdata.model.equity.MarketData;
import com.flying.scorer.model.equity.EquityScore;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface EquityScoreRepository extends JpaRepository<EquityScore, Long> {
    @Query(value = "select md from MarketData md where md.equityInfo=:info and md.date between :beginDate and :endDate and not exists(select es from EquityScore as es where es.succeed=true and md.equityInfo=es.equityInfo and md.date=es.date)")
    List<MarketData> findUnScoredMarketDataByEquityInfoAndDateBetween(@Param("info") EquityInfo info, @Param("beginDate") int beginDate, @Param("endDate") int endDate);

    List<EquityScore> findBySucceedTrue(Pageable pageable);
}
